<?php
namespace app\firm\model;

use think\Model;
use traits\model\SoftDelete;

class Order extends Model {
    
     protected $autoWriteTimestamp = true;

    use SoftDelete;

    protected $deleteTime = 'delete_time';

    public function Team() {
        return $this->hasOne('team', 'id', 'initiator')->field('team_name');
    }

    /*
     * 查询企业上传项目信息
     * @param $where where
     * @param $field field
     * @author cpy(1442435897@qq.com)
     */
    public function getInfo($where,$field = '*') {
        $res = $this->field($field)->where($where)->find();
        return empty($res)?array():$res->toArray();
    }
    
    /*
     * 查询所有企业用户项目
     * @param $where where
     * @param $field field
     * @author cpy(1442435897@qq.com)
     */
    public function selectInfo($where,$field = '*') {
        $res = $this->field($field)->where($where)->select();
        return empty($res)?array():$res->toArray();
    }
    
    /*
     * 查询所有企业用户项目
     * @param $where where
     * @param $field field
     * @author cpy(1442435897@qq.com)
     */
    public function selectGroupInfo($where,$group,$field = '*') {
        $res = $this->field($field)->where($where)->group($group)->select();
        return empty($res)?array():$res->toArray();
    }
    
    /*
     * 联合查询所有企业用户项目
     * @param $where where
     * @param $field field
     * @author cpy(1442435897@qq.com)
     */
    public function selectJoinGroupInfo($where,$group,$field = '*') {
        $res = $this->alias('a')->join('member b','b.id=a.uid')->field($field)->where($where)->group($group)->select();
        return empty($res)?array():$res->toArray();
    }
    
    /*
     * 查询所有企业用户项目
     * @param $where where
     * @param $field field
     * @author cpy(1442435897@qq.com)
     */
    public function selectLimitInfo($where,$limit,$field = '*') {
        $res = $this->field($field)->where($where)->limit($limit)->select();
        return empty($res)?array():$res->toArray();
    }

}
